<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>view/workArea/onlineService/listBySerialno</title>
		<!-- css代码 start -->
		<link href="../../../css/mui.min.css" rel="stylesheet" />
		<link href="../../../css/global.css" rel="stylesheet" />
		<link href="../../../css/style.css" rel="stylesheet" />
		<link href="../../../css/checkbox.css" rel="stylesheet" />
		<style>
			.mui-radio input[type=radio]{
				left: 0;
				top: 11px;
			}
			.mui-checkbox label, .mui-radio label{
				padding-left: 38px;
				font-size: 14px;
				color: #333333;
				padding-right: 0;
			}
			.item_box .item .text{
				display: flex;
				min-height: 30px;
				height: auto;
				line-height: 1.2;
				padding: 8px 17px;
			}
			.item_box .item .text span.l{
				width: 90px;
			}
			.item_box .item .text span.content,.item_box .item .type p span.content{
				flex: 1;
				color: inherit;
			}
			.item_box .item .type p{
				display: flex;
			}
			.item_box .item .type{
				padding-right: 10px;
			}
			.item_box .item .type p span.l{
				width: 98px;
			}

		</style>
		<!-- css代码 end -->
	</head>
	<body>
		<!-- html代码 start -->
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">请选择</h1>
		</header>
		<div class="mui-content">
			<div class="details_con" style="margin: 30px 0 0 0;">
				<div class="item_box" id="itemBox">
				</div>
			</div>
		</div>
		
		<!-- html代码 end -->

		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/utils/h.js"></script>
		<script src="../../../js/constant.js"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/utils/base64.js"></script>
		<script src="../../../js/utils/md5.js"></script>
		<script src="../../../js/utils/sortMap.js"></script>
		<script src="../../../js/utils/http.js"></script>
		<script src="../../../js/app.js"></script>
		<!-- 基础js end -->

		<script type="text/javascript" charset="utf-8">
			var backToCreateOrder; //定义点击item调用方法
			
			(function($, doc) {
				$.init();

				$.plusReady(function() {
					// 从上一个页面取值
					var self = plus.webview.currentWebview();
					var param = self.serialno;
					
					// 根据参数查询数据
					selectList(param);
					
					// 确认转移
					backToCreateOrder = function(Address, Model, Material, CustName, CustID, Instrument_ID){
						var parent = plus.webview.getWebviewById('view/workArea/onlineService/createOrder');
						mui.fire(parent, 'serialEvent', {
							"Address":Address, 
							"Model":Model, 
							"Material":Material, 
							"CustName":CustName,
							"CustID":CustID,
							"Instrument_ID":Instrument_ID
						});
						self.close();
					}
				});

			}(mui, document));
			
			function selectList(param) {
				app.showWaiting('加载中...')
				ajaxGet(BASE_URL + "cc/onlineService/getUserEqInfoBySerial", {
					"serial": param
				}, function(data) {
					app.closeWaiting()
					if (data.code == 200) { //查询成功
						var res = JSON.parse(data.data);
						// 查询成功，解析返回数据显示到页面
						if (res.status && res.status == 1) {
							var list = res.record;
							// 无数据
							if (list.length == 0) {
								h("#itemBox").html('<div class="nodata">—— 暂无数据 ——</div>');
								return false;
							}
							// 显示列表
							var str = '';
							for(var i = 0; i<list.length; i++){
								var info = list[i];
								str += '<div class="item" onclick="backToCreateOrder(\''+ info.Address +'\', \''+ info.Model +'\', \''+ info.Material +'\', \''+ info.CustName +'\', \''+ info.CustID +'\', \''+ info.Instrument_ID +'\')">';
								str += '<div class="text">';
								str += '<span class="content">'+ emptyStr(info.CustName)+'</span>';
								str += '</div>';
								str += '<div class="type">';
								str += '<p><span class="l"><img src="../../../images/icon_dz.png"/>联系地址：</span><span class="content">'+ emptyStr(info.Address) +'</span></p>';
								str += '<p><span class="l"><img src="../../../images/icon_xh.png"/>型号：</span><span class="content">'+ emptyStr(info.Model) +'</span></p>';
								str += '<p><span class="l"><img src="../../../images/icon_wlh.png"/>物料号：</span><span class="content">'+ emptyStr(info.Material) +'</span></p>';
								str += '</div>';
								str += '</div>';
							}
							h('#itemBox').html(str);
						} else {
							// app.toast(res.message);
							noData()
						}
					} else { //查询失败
						app.toast(data.msg);
						noData()
					}
				}, function(errorMsg) {
					app.closeWaiting()
					noData()
					app.toast("数据获取失败，请检查网络连接");
				});
			}
			
			function noData() {
				html = '<div class="nodata">—— 暂无数据 ——</div>';
				h("#itemBox").html(html);
			}
		</script>
		<!-- js代码 end -->
	</body>
</html>
